package com.smh.a04SetDemo1;

import java.util.LinkedHashSet;

public class LinkHashSetDemo1 {
    public static void main(String[] args) {
        //有序,不重复,无索引
        //这里的有序指的是保证存储和取出的元素顺序一致
        //原理:底层数据结构是依然哈希表，只是每个元素又额外的多了一个双链表的机制记录存储的顺序。

        Student student = new Student("asd",12,"nan");
        Student student2 = new Student("qwe",12,"nan");
        Student student3 = new Student("zxc",12,"nv");
        Student student4= new Student("fgh",12,"nan");


        LinkedHashSet<Student> linkedHashSet = new LinkedHashSet<>();

        linkedHashSet.add(student);
        linkedHashSet.add(student2);
        linkedHashSet.add(student3);
        linkedHashSet.add(student4);

        System.out.println(linkedHashSet);

    }
}
